import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/overview',
    children: [
      {
        path: 'overview',
        name: 'overview',
        component: () => import('@/views/overview/'),
        meta: {title: '数据概览', icon: 'dashboard'}
      }
    ]
  },
  {
    path: '/task_management',
    component: Layout,
    redirect: '/task_management/task_list',
    meta: {title: '任务管理', icon: 'dashboard'},
    children: [
      {
        path: 'task_list',
        name: 'task_list',
        component: () => import('@/views/Tasklist/index'),
        meta: {title: '任务列表', icon: 'dashboard'}
      },
      {
        path: 'task_review',
        name: 'task_review',
        component: () => import('@/views/task_review/index'),
        meta: {title: '任务审核', icon: 'dashboard'}
      }
    ]
  },
  {
    path: '/financial_management',
    component: Layout,
    redirect: '/financial_management/running_water',
    meta: {title: '财务管理', icon: 'dashboard'},
    children: [
      {
        path: 'running_water',
        name: 'running_water',
        component: () => import('@/views/financial_management/running_water'),
        meta: {title: '平台流水', icon: 'dashboard'}
      },
      {
        path: 'apply_for',
        name: 'apply_for',
        component: () => import('@/views/financial_management/apply_withdrawal'),
        meta: {title: '提现申请', icon: 'dashboard'}
      },
      // {
      //   path: 'finance',
      //   name: 'finance',
      //   component: () => import('@/views/financial_management/membership_flow'),
      //   meta: {title: '会员财务流水', icon: 'dashboard'}
      // },
      // {
      //   path: 'mode_payment',
      //   name: 'mode_payment',
      //   component: () => import('@/views/dashboard/index'),
      //   meta: {title: '支付方式管理', icon: 'dashboard'}
      // },
    ]
  },
  {
    path: '/member_center',
    component: Layout,
    redirect: '/member_center/member_management',
    meta: {title: '用户管理', icon: 'dashboard'},
    children: [
      {
        path: 'member_management',
        name: 'member_management',
        component: () => import('@/views/member_center/member_management/index'),
        meta: {title: '用户管理', icon: 'dashboard'},
      },
      // {
      //   path: 'level_management',
      //   name: 'level_management',
      //   component: () => import('@/views/member_center/level_management/index'),
      //   meta: {title: '等级管理', icon: 'dashboard'}
      // }
    ]
  },
  {
    path: '/agent_management',
    component: Layout,
    redirect: '/agent_management',
    children: [{
      path: 'agent_management',
      name: 'agent_management',
      component: () => import('@/views/Agent_management/index'),
      meta: {title: '商户管理', icon: 'dashboard'}
    }]
  },
  // {
  //   path: '/staff_management',
  //   component: Layout,
  //   redirect: '/staff_management',
  //   children: [{
  //     path: 'staff_management',
  //     name: 'staff_management',
  //     component: () => import('@/views/staff_management/index'),
  //     meta: {title: '员工管理', icon: 'dashboard'}
  //   }]
  // },
  {
    path: '/message_center',
    component: Layout,
    redirect: '/message_center',
    children: [{
      path: 'message_center',
      name: 'message_center',
      component: () => import('@/views/message_center'),
      // meta: {title: '公告管理', icon: 'dashboard', AttC: 10}
      meta: {title: '公告消息', icon: 'dashboard'}
      //Attc为统计数量的值，设置占位符，如果不需要则不填该字段
    }]
  },
  {
    path: '/system_setup',
    component: Layout,
    redirect: '/system_setup/menu_management',
    meta: {title: '系统设置', icon: 'dashboard'},
    children: [
      {
        path: 'menu_management',
        name: 'menu_management',
        component: () => import('@/views/system_setup/menu_management'),
        meta: {title: '菜单管理', icon: 'dashboard'}
      },
      {
        path: 'user_group',
        name: 'user_group',
        component: () => import('@/views/system_setup/user_group'),
        meta: {title: '角色管理', icon: 'dashboard'}
      },
      // {
      //   path: 'administrator_list',
      //   name: 'administrator_list',
      //   component: () => import('@/views/system_setup/administrator_list'),
      //   meta: {title: '管理员列表', icon: 'el-icon-menu'}
      // },
      // {
      //   path: 'parameter_configuration',
      //   name: 'parameter_configuration',
      //   component: () => import('@/views/system_setup/parameter_configuration'),
      //   meta: {title: '参数配置', icon: 'el-icon-menu'}
      // },
    ]
  },

  // 404 page must be placed at the end !!!
  {path: '*', redirect: '/404', hidden: true}
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({y: 0}),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
